public class Solution1768 {
    public String mergeAlternately(String word1, String word2) {
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=0;i<Math.min(word1.length(),word2.length());i++){
            stringBuilder.append(word1.charAt(i)).append(word2.charAt(i));
        }
        for (int i=Math.min(word1.length(),word2.length());i<Math.max(word1.length(), word2.length());i++){
            stringBuilder.append(word1.length()>word2.length()?word1.charAt(i):word2.charAt(i));
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution1768().mergeAlternately("abc","pqr"));
    }
}
